home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / rhythmbox / plugins / jamendo / __init__.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  4.6 KB  |  76 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import rhythmdb
  5. import rb
  6. import gobject
  7. import gtk
  8. import gtk.glade as gtk
  9. from JamendoSource import JamendoSource
  10. from JamendoConfigureDialog import JamendoConfigureDialog
  11. popup_ui = '\n<ui>\n  <popup name="JamendoSourceViewPopup">\n    <menuitem name="AddToQueueLibraryPopup" action="AddToQueue"/>\n    <menuitem name="JamendoDownloadAlbum" action="JamendoDownloadAlbum"/>\n    <menuitem name="JamendoDonateArtist" action="JamendoDonateArtist"/>\n    <separator/>\n    <menuitem name="BrowseGenreLibraryPopup" action="BrowserSrcChooseGenre"/>\n    <menuitem name="BrowseArtistLibraryPopup" action="BrowserSrcChooseArtist"/>\n    <menuitem name="BrowseAlbumLibraryPopup" action="BrowserSrcChooseAlbum"/>\n    <separator/>\n    <menuitem name="PropertiesLibraryPopup" action="MusicProperties"/>\n  </popup>\n</ui>\n'
  12.  
  13. class Jamendo(rb.Plugin):
  14.     
  15.     def __init__(self):
  16.         rb.Plugin.__init__(self)
  17.  
  18.     
  19.     def activate(self, shell):
  20.         self.db = shell.get_property('db')
  21.         self.entry_type = self.db.entry_register_type('JamendoEntryType')
  22.         self.entry_type.can_sync_metadata = True
  23.         self.entry_type.sync_metadata = None
  24.         group = rb.rb_source_group_get_by_name('stores')
  25.         if not group:
  26.             group = rb.rb_source_group_register('stores', _('Stores'), rb.SOURCE_GROUP_CATEGORY_FIXED)
  27.         
  28.         theme = gtk.icon_theme_get_default()
  29.         rb.append_plugin_source_path(theme, '/icons/')
  30.         (width, height) = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR)
  31.         icon = rb.try_load_icon(theme, 'jamendo', width, 0)
  32.         self.source = gobject.new(JamendoSource, shell = shell, entry_type = self.entry_type, plugin = self, icon = icon, source_group = group)
  33.         shell.register_entry_type_for_source(self.source, self.entry_type)
  34.         shell.append_source(self.source, None)
  35.         manager = shell.get_player().get_property('ui-manager')
  36.         action = gtk.Action('JamendoDownloadAlbum', _('_Download Album'), _('Download this album using BitTorrent'), 'gtk-save')
  37.         action.connect(('activate',), (lambda a: shell.get_property('selected-source').download_album()))
  38.         self.action_group = gtk.ActionGroup('JamendoPluginActions')
  39.         self.action_group.add_action(action)
  40.         action = gtk.Action('JamendoDonateArtist', _('_Donate to Artist'), _('Donate Money to this Artist'), 'gtk-jump-to')
  41.         action.connect(('activate',), (lambda a: shell.get_property('selected-source').launch_donate()))
  42.         self.action_group.add_action(action)
  43.         manager.insert_action_group(self.action_group, 0)
  44.         self.ui_id = manager.add_ui_from_string(popup_ui)
  45.         manager.ensure_update()
  46.         self.pec_id = shell.get_player().connect('playing-song-changed', self.playing_entry_changed)
  47.  
  48.     
  49.     def deactivate(self, shell):
  50.         manager = shell.get_player().get_property('ui-manager')
  51.         manager.remove_ui(self.ui_id)
  52.         manager.remove_action_group(self.action_group)
  53.         self.action_group = None
  54.         shell.get_player().disconnect(self.pec_id)
  55.         self.db.entry_delete_by_type(self.entry_type)
  56.         self.db.commit()
  57.         self.db = None
  58.         self.entry_type = None
  59.         self.source.delete_thyself()
  60.         self.source = None
  61.  
  62.     
  63.     def create_configure_dialog(self, dialog = None):
  64.         if not dialog:
  65.             glade_file = self.find_file('jamendo-prefs.glade')
  66.             dialog = JamendoConfigureDialog(glade_file).get_dialog()
  67.         
  68.         dialog.present()
  69.         return dialog
  70.  
  71.     
  72.     def playing_entry_changed(self, sp, entry):
  73.         self.source.playing_entry_changed(entry)
  74.  
  75.  
  76.